import CONSTANT from '@/common/constants.js';
import http from '@/common/http.js';
import Countup from 'vux/src/components/countup/index.vue'
export default {
  name: 'loveRoad',
  components: { Countup },
  data () {
    return {
      userId: '',
      startMoney: 0,
      endMoney: 0,
      startPeopleNum: 0,
      endPeopleNum: 0,
      startValone: 0,
      endValone: 0,
      startValtwo: 0,
      endValtwo: 0,
      startValthree: 0,
      endValthree: 0,
      width: '200px',
      obj: {}
    }
  },
  mounted () {
    document.body.scrollTop = document.documentElement.scrollTop = 0;
    let openid = sessionStorage.getItem("openid")
    if (openid == null || openid == '' || openid == 'undefined') {
      sessionStorage.setItem('openid', this.$route.query.openId)
      sessionStorage.setItem('userId', this.$route.query.userId)
      sessionStorage.setItem('wxAvatar', this.$route.query.wxAvatar)
      sessionStorage.setItem('nickName', this.$route.query.nickName)
      let openid = sessionStorage.getItem("openid")
      if (openid == null || openid == '' || openid == 'undefined') {
        // alert('进行页面的跳转')
        window.location.href = 'http://www.qqchou.org/a/wxinterface/wxOAuth?category=6'
      }
    }
    if (this.$emit('ShareAppMessage')) {
      this.$emit('ShareAppMessage', '亲青筹-成长历程', '“亲青筹”由浙江团省委、青基会发起设立，通过众筹善款，服务青少年成长。', 'http://www.qqchou.org/a/wxinterface/wxOAuth?category=6', this.imageUrl.imageUrl+'/userfiles/2/images/1513911875.png')
    }
    if (this.$emit('ifOpenid')) {
      this.$emit('ifOpenid', this.$route.path)
    }
    if (this.$route.query.openId) {
      window.location.reload()
    }
    this.userId = window.sessionStorage.getItem('userId')
    http.post(CONSTANT.GROWTH_PROCESS, {userId: this.userId}, (res) => {
      console.log(res)
      if (res.code == 200) {
        this.obj = res.obj
        this.endValone = this.obj.number
        this.endValtwo = this.obj.project
        this.endValthree = this.obj.person
        this.endPeopleNum = this.obj.people
        this.endMoney = parseFloat(this.obj.qqcTotalMoney)
        console.log(this.endMoney)
      }
    })
  },
  methods: {
    gouserDonation () {
      this.$router.push({path: '/userdonate', query: {'showWitch': 1}})
    },
    goHome () {
      this.$router.push({path: '/Hello'})
    }
  }
}
